package com.axjy.web;

import com.axjy.pojo.User;
import com.axjy.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    @Resource
    private UserService userService;


    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @PostMapping("/login")
    public String login(String name, String password, HttpSession session){
       User loginUser= userService.login(name,password);
       if(loginUser==null){
           return "login";
       }
       session.setAttribute("loginUser",loginUser);
       return "redirect:/house/guanli";
    }




}
